-- Create Scripts:

USE [ConfigService]
GO
/****** Object:  Table [dbo].[Log]    Script Date: 10/24/2008 12:53:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Log](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Date] [datetime] NOT NULL,
	[UID] [varchar](36) NULL,
	[IsRootNode] [bit] NULL,
	[Thread] [varchar](32) NOT NULL,
	[Level] [varchar](512) NOT NULL,
	[Logger] [varchar](512) NOT NULL,
	[Message] [varchar](4000) NOT NULL,
	[Context] [varchar](512) NULL,
	[Exception] [varchar](2000) NULL,
	[Identity] [varchar](255) NULL,
 CONSTRAINT [PK__Log__345EC57D] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

/****** Object:  Table [dbo].[ConfigType]    Script Date: 09/25/2008 16:15:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ConfigType](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](MAX) NULL,
	[Modified] [smalldatetime] NULL,
	[Created] [smalldatetime] NULL,
	[Name] [varchar](50) NULL,
 CONSTRAINT [PK_ConfigType] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

/****** Object:  Table [dbo].[Mode]    Script Date: 09/25/2008 16:16:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Mode](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) NULL,
	[Description] [varchar](MAX) NULL,
	[Modified] [smalldatetime] NULL,
	[Created] [smalldatetime] NULL,
 CONSTRAINT [PK_Mode] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

/****** Object:  Table [dbo].[ApplicationModeModified]    Script Date: 10/02/2008 11:33:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ApplicationModeModified](
	[ApplicationId] [int] NOT NULL,
	[ModeId] [int] NOT NULL,
	[Modified] [datetime] NULL,
 CONSTRAINT [PK_ApplicationModeModified] PRIMARY KEY CLUSTERED 
(
	[ApplicationId] ASC,
	[ModeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

USE [ConfigService]
GO
/****** Object:  Table [dbo].[Application]    Script Date: 10/24/2008 12:19:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Application](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](max) NULL,
	[Modified] [smalldatetime] NULL,
	[Created] [smalldatetime] NULL,
	[AppCode] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Application] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [CONSTR_APPCODE] UNIQUE NONCLUSTERED 
(
	[AppCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

/****** Object:  Table [dbo].[Config]    Script Date: 10/02/2008 17:28:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Config](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](max) NULL,
	[Key] [varchar](50) NOT NULL,
	[Value] [varchar](50) NULL,
	[Modified] [smalldatetime] NULL,
	[Created] [smalldatetime] NULL,
	[ModeId] [int] NOT NULL,
	[ApplicationId] [int] NOT NULL,
	[ConfigType] [int] NOT NULL,
 CONSTRAINT [PK_Config] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [CONSTR_KEY] UNIQUE NONCLUSTERED 
(
	[Key] ASC,
	[ApplicationId] ASC,
	[ModeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Config]  WITH CHECK ADD  CONSTRAINT [FK_Config_Application] FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[Application] ([Id])
GO
ALTER TABLE [dbo].[Config] CHECK CONSTRAINT [FK_Config_Application]
GO
ALTER TABLE [dbo].[Config]  WITH CHECK ADD  CONSTRAINT [FK_Config_ConfigType] FOREIGN KEY([ConfigType])
REFERENCES [dbo].[ConfigType] ([Id])
GO
ALTER TABLE [dbo].[Config] CHECK CONSTRAINT [FK_Config_ConfigType]
GO
ALTER TABLE [dbo].[Config]  WITH CHECK ADD  CONSTRAINT [FK_Config_Mode] FOREIGN KEY([ModeId])
REFERENCES [dbo].[Mode] ([Id])
GO
ALTER TABLE [dbo].[Config] CHECK CONSTRAINT [FK_Config_Mode]





